﻿#ifndef INPUT_H
#define INPUT_H

#include <QWidget>
#include "QSqlDatabase"
#include "QSqlQueryModel"
#include <QDate>
#include "account_db.h"

namespace Ui {
class Input;
}

class Input : public QWidget
{
    Q_OBJECT

public:
    explicit Input(QWidget *parent = nullptr,account_db *input_account_db = nullptr);
    ~Input();

    void database_add(
                   QString person,
                   QString amount,
                   QString group,
                   QString date,
                   QString remark);
    void database_delete(
                   QString person,
                   QString amount,
                   QString group,
                   QString date,
                   QString remark);
    char M_Sql_Update(QString m_name, QString m_type, int m_num,QString m_date);
    void database_select(QList<QString> row_list, QList<QString> condition_list);
    bool Check_Same(QString m_name, QString m_type, QString m_date);
//    int M_Sql_Id();
    //建立数据库
    QString  input_db_name;
    QList<QString> select_check();
    QTime *m_time;
    QSqlQueryModel *model;
    account_db *input_data_db;  //操作存储数据库的对象
public slots:
    void show_groups(QStringList g_list);
private slots:
    void on_cancel_clicked();

    void on_btn_in_clicked();
    void Timer_Handle();
    void on_btn_in_2_clicked();

    void on_btn_in_3_clicked();

    void on_pushButton_clicked();

private:

    Ui::Input *ui;

    //获取当地时间
    QString now_time;
    //输入预处理函数
    bool Pretre_Cheack(char func);
    bool Pretre_Cheack(char func, QList<QString> &list, QList<QString> &condition_list);
    QList<QString> get_input_data();
    //当前ID
    int ID;
    //操作的类型
    enum {
      func_add  = 0  ,
      func_update   ,
      func_select ,
      func_delet
    }Input_Fun;
signals:
    void Delate_Win(QString win);
    void Text_Message(QString Message);
};

#endif // INPUT_H
